package com.csq.cms.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.csq.cms.mapper.ParttimeInfoMapper;
import com.csq.cms.service.ParttimeTypeService;
import com.csq.manager.mapper.ParttimeTypeMapper;
import com.csq.manager.pojo.ParttimeType;
import com.csq.manager.pojo.ParttimeTypeExample;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
@Service
public class ParttimeTypeServiceImpl implements ParttimeTypeService {

	@Autowired
	private ParttimeTypeMapper parttimeTypeMapper;
	
	@Autowired
	private ParttimeInfoMapper parttimeInfoMapper;
	
	
	@Override
	public PageInfo<ParttimeType> getAllParttimeType(Integer page, Integer row) {
		// TODO Auto-generated method stub
		
		
		if (page == null) {
			page = 1;
		}
		if (row == null) {
			row = 30;
		}

		// 分页设置
		PageHelper.startPage(page, row);
		// 执行查询
		ParttimeTypeExample parttimeTypeExample = new ParttimeTypeExample();
		
		List<ParttimeType> list = parttimeTypeMapper.selectByExample(parttimeTypeExample);
		// 取分页信息
		PageInfo<ParttimeType> pageInfo = new PageInfo<>(list);
		System.out.println("总记录数：" + pageInfo.getTotal());
		System.out.println("总页数：" + pageInfo.getPages());
		System.out.println(list.size());

		return pageInfo;
	}


	@Override
	public PageInfo<ParttimeType> getAllParttimeTypeByEnterpriseId(Integer enterpriseId,
			Integer page, Integer row) {
		if (page == null) {
			page = 1;
		}
		if (row == null) {
			row = 30;
		}

		// 分页设置
		PageHelper.startPage(page, row);
		
		List<ParttimeType> list = parttimeInfoMapper.getAllParttimeTypeByEnterpriseId(enterpriseId);
		
		// 取分页信息
		PageInfo<ParttimeType> pageInfo = new PageInfo<>(list);
		System.out.println("总记录数：" + pageInfo.getTotal());
		System.out.println("总页数：" + pageInfo.getPages());
		System.out.println(list.size());

		return pageInfo;
	}

}
